<!doctype html>

<html>
<head>
  <link rel="shortcut icon" href="static/images/favicon.ico" type="image/x-icon">
  <title>countrylanguagenames_test.js (Closure Library API Documentation - JavaScript)</title>
  <link rel="stylesheet" href="static/css/base.css">
  <link rel="stylesheet" href="static/css/doc.css">
  <link rel="stylesheet" href="static/css/sidetree.css">
  <link rel="stylesheet" href="static/css/prettify.css">

  <script>
     var _staticFilePath = "static/";
     var _typeTreeName = "goog";
     var _fileTreeName = "Source";
  </script>

  <script src="static/js/doc.js">
  </script>


  <meta charset="utf8">
</head>

<body onload="grokdoc.onLoad();">

<div id="header">
  <div class="g-section g-tpl-50-50 g-split">
    <div class="g-unit g-first">
      <a id="logo" href="index.html">Closure Library API Documentation</a>
    </div>

    <div class="g-unit">
      <div class="g-c">
        <strong>Go to class or file:</strong>
        <input type="text" id="ac">
      </div>
    </div>
  </div>
</div>

<div class="clear"></div>

<h2><a href="local_closure_goog_locale_countrylanguagenames_test.js.html">countrylanguagenames_test.js</a></h2>

<pre class="prettyprint lang-js">
<a name="line1"></a>// Copyright 2006 The Closure Library Authors. All Rights Reserved.
<a name="line2"></a>//
<a name="line3"></a>// Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);
<a name="line4"></a>// you may not use this file except in compliance with the License.
<a name="line5"></a>// You may obtain a copy of the License at
<a name="line6"></a>//
<a name="line7"></a>//      http://www.apache.org/licenses/LICENSE-2.0
<a name="line8"></a>//
<a name="line9"></a>// Unless required by applicable law or agreed to in writing, software
<a name="line10"></a>// distributed under the License is distributed on an &quot;AS-IS&quot; BASIS,
<a name="line11"></a>// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
<a name="line12"></a>// See the License for the specific language governing permissions and
<a name="line13"></a>// limitations under the License.
<a name="line14"></a>
<a name="line15"></a>goog.provide(&#39;goog.locale.countryLanguageNamesTest&#39;);
<a name="line16"></a>goog.setTestOnly(&#39;goog.locale.countryLanguageNamesTest&#39;);
<a name="line17"></a>
<a name="line18"></a>goog.require(&#39;goog.locale&#39;);
<a name="line19"></a>goog.require(&#39;goog.testing.jsunit&#39;);
<a name="line20"></a>
<a name="line21"></a>var LocaleNameConstants_en;
<a name="line22"></a>
<a name="line23"></a>function setUpPage() {
<a name="line24"></a>  // Test data from //googledata/i18n/js_locale_data/LocaleNameConstants__de.js
<a name="line25"></a>  var LocaleNameConstants_de = {
<a name="line26"></a>    LANGUAGE: {
<a name="line27"></a>      &#39;cad&#39;: &#39;Caddo&#39;,
<a name="line28"></a>      &#39;fr&#39;: &#39;Franz\u00f6sisch&#39;,
<a name="line29"></a>      &#39;fr_CA&#39;: &#39;Canadian French&#39;,
<a name="line30"></a>      &#39;fr_CH&#39;: &#39;Swiss French&#39;, &#39;zh&#39;: &#39;Chinesisch&#39;,
<a name="line31"></a>      &#39;zh_Hans&#39;: &#39;Chinesisch (vereinfacht)&#39;,
<a name="line32"></a>      &#39;zh_Hant&#39;: &#39;Chinesisch (traditionell)&#39;
<a name="line33"></a>    },
<a name="line34"></a>    COUNTRY: {
<a name="line35"></a>      &#39;CN&#39;: &#39;China&#39;,
<a name="line36"></a>      &#39;ES&#39;: &#39;Spanien&#39;,
<a name="line37"></a>      &#39;FR&#39;: &#39;Frankreich&#39;
<a name="line38"></a>    }
<a name="line39"></a>  };
<a name="line40"></a>  registerLocalNameConstants(LocaleNameConstants_de, &#39;de&#39;);
<a name="line41"></a>
<a name="line42"></a>  // Test data from //googledata/i18n/js_locale_data/LocaleNameConstants__en.js
<a name="line43"></a>  LocaleNameConstants_en = {
<a name="line44"></a>    LANGUAGE: {
<a name="line45"></a>      &#39;cad&#39;: &#39;Caddo&#39;,
<a name="line46"></a>      &#39;fr&#39;: &#39;French&#39;,
<a name="line47"></a>      &#39;fr_CA&#39;: &#39;Canadian French&#39;,
<a name="line48"></a>      &#39;fr_CH&#39;: &#39;Swiss French&#39;,
<a name="line49"></a>      &#39;zh&#39;: &#39;Chinese&#39;,
<a name="line50"></a>      &#39;zh_Hans&#39;: &#39;Simplified Chinese&#39;,
<a name="line51"></a>      &#39;zh_Hant&#39;: &#39;Traditional Chinese&#39;
<a name="line52"></a>    },
<a name="line53"></a>    COUNTRY: {
<a name="line54"></a>      &#39;CN&#39;: &#39;China&#39;,
<a name="line55"></a>      &#39;ES&#39;: &#39;Spain&#39;,
<a name="line56"></a>      &#39;FR&#39;: &#39;France&#39;
<a name="line57"></a>    }
<a name="line58"></a>  };
<a name="line59"></a>  registerLocalNameConstants(LocaleNameConstants_en, &#39;en&#39;);
<a name="line60"></a>
<a name="line61"></a>  goog.locale.setLocale(&#39;de&#39;);
<a name="line62"></a>}
<a name="line63"></a>
<a name="line64"></a>function testLoadLoacleSymbols() {
<a name="line65"></a>  var result = goog.locale.getLocalizedCountryName(&#39;fr-FR&#39;);
<a name="line66"></a>  assertEquals(&#39;Frankreich&#39;, result);
<a name="line67"></a>}
<a name="line68"></a>
<a name="line69"></a>function testGetNativeCountryName() {
<a name="line70"></a>  var result = goog.locale.getNativeCountryName(&#39;de-DE&#39;);
<a name="line71"></a>  assertEquals(&#39;Deutschland&#39;, result);
<a name="line72"></a>
<a name="line73"></a>  result = goog.locale.getNativeCountryName(&#39;de_DE&#39;);
<a name="line74"></a>  assertEquals(&#39;Deutschland&#39;, result);
<a name="line75"></a>
<a name="line76"></a>  result = goog.locale.getNativeCountryName(&#39;und&#39;);
<a name="line77"></a>  assertEquals(&#39;und&#39;, result);
<a name="line78"></a>
<a name="line79"></a>  result = goog.locale.getNativeCountryName(&#39;de-CH&#39;);
<a name="line80"></a>  assertEquals(&#39;Schweiz&#39;, result);
<a name="line81"></a>
<a name="line82"></a>  result = goog.locale.getNativeCountryName(&#39;fr-CH&#39;);
<a name="line83"></a>  assertEquals(&#39;Suisse&#39;, result);
<a name="line84"></a>
<a name="line85"></a>  result = goog.locale.getNativeCountryName(&#39;it-CH&#39;);
<a name="line86"></a>  assertEquals(&#39;Svizzera&#39;, result);
<a name="line87"></a>}
<a name="line88"></a>
<a name="line89"></a>function testGetLocalizedCountryName() {
<a name="line90"></a>  var result = goog.locale.getLocalizedCountryName(&#39;es-ES&#39;);
<a name="line91"></a>  assertEquals(&#39;Spanien&#39;, result);
<a name="line92"></a>
<a name="line93"></a>  result = goog.locale.getLocalizedCountryName(&#39;es-ES&#39;, LocaleNameConstants_en);
<a name="line94"></a>  assertEquals(&#39;Spain&#39;, result);
<a name="line95"></a>
<a name="line96"></a>  result = goog.locale.getLocalizedCountryName(&#39;zh-CN-cmn&#39;);
<a name="line97"></a>  assertEquals(&#39;China&#39;, result);
<a name="line98"></a>
<a name="line99"></a>  result = goog.locale.getLocalizedCountryName(&#39;zh_CN_cmn&#39;);
<a name="line100"></a>  assertEquals(&#39;China&#39;, result);
<a name="line101"></a>
<a name="line102"></a>  // &#39;und&#39; is a non-existing locale, default behavior is to
<a name="line103"></a>  // return the locale name itself if no mapping is found.
<a name="line104"></a>  result = goog.locale.getLocalizedCountryName(&#39;und&#39;);
<a name="line105"></a>  assertEquals(&#39;und&#39;, result);
<a name="line106"></a>}
<a name="line107"></a>
<a name="line108"></a>function testGetNativeLanguageName() {
<a name="line109"></a>  var result = goog.locale.getNativeLanguageName(&#39;fr&#39;);
<a name="line110"></a>  assertEquals(&#39;fran\u00E7ais&#39;, result);
<a name="line111"></a>
<a name="line112"></a>  result = goog.locale.getNativeLanguageName(&#39;fr-latn-FR&#39;);
<a name="line113"></a>  assertEquals(&#39;fran\u00E7ais&#39;, result);
<a name="line114"></a>
<a name="line115"></a>  result = goog.locale.getNativeLanguageName(&#39;fr_FR&#39;);
<a name="line116"></a>  assertEquals(&#39;fran\u00E7ais&#39;, result);
<a name="line117"></a>
<a name="line118"></a>  result = goog.locale.getNativeLanguageName(&#39;error&#39;);
<a name="line119"></a>  assertEquals(&#39;error&#39;, result);
<a name="line120"></a>}
<a name="line121"></a>
<a name="line122"></a>function testGetLocalizedLanguageName() {
<a name="line123"></a>  var result = goog.locale.getLocalizedLanguageName(&#39;fr&#39;);
<a name="line124"></a>  assertEquals(&#39;Franz\u00F6sisch&#39;, result);
<a name="line125"></a>
<a name="line126"></a>  result = goog.locale.getLocalizedLanguageName(&#39;fr&#39;,
<a name="line127"></a>      LocaleNameConstants_en);
<a name="line128"></a>  assertEquals(&#39;French&#39;, result);
<a name="line129"></a>
<a name="line130"></a>  result = goog.locale.getLocalizedLanguageName(&#39;fr-latn-FR&#39;);
<a name="line131"></a>  assertEquals(&#39;Franz\u00F6sisch&#39;, result);
<a name="line132"></a>
<a name="line133"></a>  result = goog.locale.getLocalizedLanguageName(&#39;fr_FR&#39;);
<a name="line134"></a>  assertEquals(&#39;Franz\u00F6sisch&#39;, result);
<a name="line135"></a>
<a name="line136"></a>  result = goog.locale.getLocalizedLanguageName(&#39;cad&#39;);
<a name="line137"></a>  assertEquals(&#39;Caddo&#39;, result);
<a name="line138"></a>
<a name="line139"></a>  result = goog.locale.getLocalizedLanguageName(&#39;error&#39;);
<a name="line140"></a>  assertEquals(&#39;error&#39;, result);
<a name="line141"></a>
<a name="line142"></a>  result = goog.locale.getLocalizedLanguageName(&#39;zh_Hans&#39;,
<a name="line143"></a>      LocaleNameConstants_en);
<a name="line144"></a>  assertEquals(&#39;Simplified Chinese&#39;, result);
<a name="line145"></a>}
<a name="line146"></a>
<a name="line147"></a>
<a name="line148"></a>function testGetLocalizedLanguageNameForGivenSymbolset() {
<a name="line149"></a>  var result = goog.locale.getLocalizedCountryName(&#39;fr-FR&#39;);
<a name="line150"></a>  assertEquals(&#39;Frankreich&#39;, result);
<a name="line151"></a>
<a name="line152"></a>  result = goog.locale.getLocalizedCountryName(
<a name="line153"></a>      &#39;fr-FR&#39;,
<a name="line154"></a>      LocaleNameConstants_en);
<a name="line155"></a>  assertEquals(&#39;France&#39;, result);
<a name="line156"></a>
<a name="line157"></a>  result = goog.locale.getLocalizedCountryName(&#39;fr-FR&#39;);
<a name="line158"></a>  assertEquals(&#39;Frankreich&#39;, result);
<a name="line159"></a>}
<a name="line160"></a>
<a name="line161"></a>/**
<a name="line162"></a> * Valid combination of sub tags:
<a name="line163"></a> *  1)  LanguageSubtag&#39;-&#39;RegionSubtag
<a name="line164"></a> *  2)  LanguageSubtag&#39;-&#39;ScriptSubtag&#39;-&#39;RegionSubtag
<a name="line165"></a> *  3)  LanguageSubtag&#39;-&#39;RegionSubtag&#39;-&#39;VariantSubtag
<a name="line166"></a> *  4)  LanguageSubtag&#39;-&#39;ScriptSubTag&#39;-&#39;RegionSubtag&#39;-&#39;VariantSubtag
<a name="line167"></a> */
<a name="line168"></a>
<a name="line169"></a>function testGetRegionSubTag() {
<a name="line170"></a>
<a name="line171"></a>  var result = goog.locale.getRegionSubTag(&#39;de-CH&#39;);
<a name="line172"></a>  assertEquals(&#39;CH&#39;, result);
<a name="line173"></a>
<a name="line174"></a>  result = goog.locale.getRegionSubTag(&#39;de-latn-CH&#39;);
<a name="line175"></a>  assertEquals(&#39;CH&#39;, result);
<a name="line176"></a>
<a name="line177"></a>  result = goog.locale.getRegionSubTag(&#39;de_latn_CH&#39;);
<a name="line178"></a>  assertEquals(&#39;CH&#39;, result);
<a name="line179"></a>
<a name="line180"></a>  result = goog.locale.getRegionSubTag(&#39;de-CH-xxx&#39;);
<a name="line181"></a>  assertEquals(&#39;CH&#39;, result);
<a name="line182"></a>
<a name="line183"></a>  result = goog.locale.getRegionSubTag(&#39;de-latn-CH-xxx&#39;);
<a name="line184"></a>  assertEquals(&#39;CH&#39;, result);
<a name="line185"></a>
<a name="line186"></a>  result = goog.locale.getRegionSubTag(&#39;es-latn-419-xxx&#39;);
<a name="line187"></a>  assertEquals(&#39;419&#39;, result);
<a name="line188"></a>
<a name="line189"></a>  result = goog.locale.getRegionSubTag(&#39;es_latn_419_xxx&#39;);
<a name="line190"></a>  assertEquals(&#39;419&#39;, result);
<a name="line191"></a>
<a name="line192"></a>  // No region sub tag present
<a name="line193"></a>  result = goog.locale.getRegionSubTag(&#39;de&#39;);
<a name="line194"></a>  assertEquals(&#39;&#39;, result);
<a name="line195"></a>}
<a name="line196"></a>
<a name="line197"></a>function testGetLanguageSubTag() {
<a name="line198"></a>
<a name="line199"></a>  var result = goog.locale.getLanguageSubTag(&#39;de&#39;);
<a name="line200"></a>  assertEquals(&#39;de&#39;, result);
<a name="line201"></a>
<a name="line202"></a>  result = goog.locale.getLanguageSubTag(&#39;de-DE&#39;);
<a name="line203"></a>  assertEquals(&#39;de&#39;, result);
<a name="line204"></a>
<a name="line205"></a>  result = goog.locale.getLanguageSubTag(&#39;de-latn-DE-xxx&#39;);
<a name="line206"></a>  assertEquals(&#39;de&#39;, result);
<a name="line207"></a>
<a name="line208"></a>  result = goog.locale.getLanguageSubTag(&#39;nds&#39;);
<a name="line209"></a>  assertEquals(&#39;nds&#39;, result);
<a name="line210"></a>
<a name="line211"></a>  result = goog.locale.getLanguageSubTag(&#39;nds-DE&#39;);
<a name="line212"></a>  assertEquals(&#39;nds&#39;, result);
<a name="line213"></a>}
<a name="line214"></a>
<a name="line215"></a>function testGetScriptSubTag() {
<a name="line216"></a>
<a name="line217"></a>  var result = goog.locale.getScriptSubTag(&#39;fr&#39;);
<a name="line218"></a>  assertEquals(&#39;&#39;, result);
<a name="line219"></a>
<a name="line220"></a>  result = goog.locale.getScriptSubTag(&#39;fr-Latn&#39;);
<a name="line221"></a>  assertEquals(&#39;Latn&#39;, result);
<a name="line222"></a>
<a name="line223"></a>  result = goog.locale.getScriptSubTag(&#39;fr-Arab-AA&#39;);
<a name="line224"></a>  assertEquals(&#39;Arab&#39;, result);
<a name="line225"></a>
<a name="line226"></a>  result = goog.locale.getScriptSubTag(&#39;de-Latin-DE&#39;);
<a name="line227"></a>  assertEquals(&#39;&#39;, result);
<a name="line228"></a>
<a name="line229"></a>  result = goog.locale.getScriptSubTag(&#39;srn-Ar-DE&#39;);
<a name="line230"></a>  assertEquals(&#39;&#39;, result);
<a name="line231"></a>}
</pre>


</body>
</html>
